{template nheader.html}

<div class="page-bar">
	<ul class="page-breadcrumb">
		<li><a href="{dr_url('home/cache')}" class="blue"> <i class="fa fa-refresh"></i> {fc_lang('更新缓存')}</a> <i class="fa fa-circle"></i></li>
		<li><a href="{dr_url('check/index')}"> <i class="icon-compass"></i> {fc_lang('系统体检')}</a> <i class="fa fa-circle"></i></li>
		<li><a href="{dr_url('check/phpinfo')}" target="_blank"> <i class="fa fa-pie-chart"></i> {fc_lang('PHP环境')}</a></li>
	</ul>
</div>



<h3 class="page-title">
	<small><a href="javascript:dr_update_cache_all();">{fc_lang('单击一键更新常用网站缓存')}</a></small>
</h3>

<form class="form-horizontal" action="" method="post" id="myform" name="myform">
	<div class="portlet mylistbody">

		<div class="portlet-body">
			<div class="table-scrollable">
				<table class="mytable table table-striped table-bordered table-hover table-checkable dataTable">
					<thead>
					<tr>
						<th width="55"> </th>
						<th> {fc_lang('更新项目')} </th>
						<th width="400"> </th>
					</tr>
					</thead>
					<tbody>
					{loop $list $id $t}
					<tr>
						<td>
							<span class="badge badge-success"> {$id+1} </span>
						</td>
						<td>
							{fc_lang($t[0])}
						</td>
						<td>
							<label>
								<a href="javascript:my_update_cache('{$id}', '{$t[1]}');" class="btn red btn-xs"><i class="fa fa-refresh"></i> {fc_lang('立即更新')} </a>
							</label>
							<label id="dr_{$id}_result" >

							</label>
						</td>
					</tr>
					{/loop}
					<tr>
						<td>
							<span class="badge badge-success"> {$id+2} </span>
						</td>
						<td>
							{fc_lang('重新生成附件缓存')}
						</td>
						<td>
							<label>
								<a href="{dr_url("attachment/cache")}" class="btn red btn-xs"><i class="fa fa-refresh"></i> {fc_lang('立即生成')} </a>
							</label>
						</td>
					</tr>
					<tr>
						<td>
							<span class="badge badge-success"> {$id+3} </span>
						</td>
						<td>
							{fc_lang('删除缩略图缓存文件')}
						</td>
						<td>
							<label>
								<a href="javascript:;" onclick="return dr_confirm_url('<font color=red><b>该操作会影响到生成静态后的页面图片显示，操作之后请重新生成网站的静态页面，您确定吗？</b></font>','{dr_url("api/cthumb")}');" class="btn red btn-xs"><i class="fa fa-refresh"></i> {fc_lang('立即清理')} </a>
							</label>
						</td>
					</tr>
					<tr>
						<td>
							<span class="badge badge-success"> {$id+4} </span>
						</td>
						<td>
							{fc_lang('检查Bom非法字符串和清理.DS_Store文件')}
						</td>
						<td>
							<label>
								<a href="javascript:dr_dom();" class="btn red btn-xs"><i class="fa fa-refresh"></i> {fc_lang('立即检查')} </a>
							</label>
							<label id="dr_dom_result"></label>
						</td>
					</tr>

					</tbody>
				</table>
			</div>
		</div>
	</div>
</form>

<script>
	function dr_dom() {
        var d = top.dialog({
            title: lang["tips"],
            fixed: true,
            content: '<img src="/statics/js/skins/icons/question.png"> {fc_lang("检测时间可能会很长，确定继续吗？")}',
            okValue: lang['ok'],
            ok: function() {
                var url ="{dr_url('home/dom')}";
                var obj = $('#dr_dom_result');
                obj.html("<img style='height:17px' src='{THEME_PATH}admin/images/mloading.gif' />");
                $.ajax({
                    type: "GET",
                    url: url,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 1) {
                            obj.html('<font color="green">{fc_lang("检测完成")}</font>');
                        } else {
                            obj.html('<a href="javascript:;" onclick="dr_show_file_code(\'{fc_lang('查看文件')}\', \'{dr_url('system/debug_file', array('time'=>SYS_TIME))}\')" style="color:red">'+data.code+'</a>');
                        }
                    },
                    error: function(HttpRequest, ajaxOptions, thrownError) {

                    }
                });
            },
            cancelValue: lang['cancel'],
            cancel: function() {}
        });
        d.show()

    }
    function my_update_cache(id, m) {

        var obj = $('#dr_'+id+'_result');
        obj.html("<img style='height:17px' src='{THEME_PATH}admin/images/mloading.gif' />");

        if (m == 'app') {
            obj.html('<font color="green">{fc_lang("更新完成")}</font>');
            {loop $aurl $url}
            $.ajax({
                type: "GET",
                url: "{$url}&"+Math.random(),
                dataType: "text",
                success: function (data) {

                },
                error: function(HttpRequest, ajaxOptions, thrownError) {

                }
            });
            {/loop}

		} else {
            $.ajax({
                type: "GET",
                dataType: "json",
                url: "{SELF}?c=home&m=cache&at="+m,
                success: function (json) {
                    if (json.code == 0) {
                        obj.html('<font color="red">'+json.msg+'</font>');
                    } else {
                        obj.html('<font color="green">{fc_lang("更新完成")}</font>');
                    }
                },
                error: function(HttpRequest, ajaxOptions, thrownError) {
                    obj.html('<a href="javascript:;" onclick="dr_show_file_code(\'{fc_lang('查看文件')}\', \'{dr_url('system/debug_file', array('time'=>SYS_TIME))}\')" style="color:red">{fc_lang("系统崩溃，请单击把错误日志发给官方处理")}</a>');
                }
            });
		}


    }
    function dr_update_cache_all() {
        {loop $list $id $t}
		{if !$t[2]}
        my_update_cache('{$id}', '{$t[1]}');
        {/if}
        {/loop}
    }
</script>


{template footer.html}